<!--Start Content-->
<div id="content" class="col-xs-12 col-sm-10">
	<div class="preloader" style="display: none;">
		<img src="images/devoops_getdata.gif" class="devoops-getdata" alt="preloader">
	</div>
	<div id="ajax-content">
		<div class="row">
			<div id="breadcrumb" class="col-xs-12">
				<ol class="breadcrumb">
					<li><a href="index.html"><?php echo __("Home"); ?></a></li>
					<li><a href="#"><?php echo __("Nodes"); ?></a></li>
				</ol>
			</div>
		</div>

		<div id="dashboard-header" class="row">
			<div class="col-xs-10 col-sm-2">
				<h3><?php echo __('Nodes list') ?></h3>
			</div>
			<?php 
			$site_url = apAuthpuppyConfig::getConfigOption("main_url");
			$logo = apAuthpuppyConfig::getConfigOption("logo");

			if (!is_null($site_url)): ?>
			<a href="<?php echo $site_url?>">
			<?php endif; 
			if (!is_null($logo)) :
			   echo image_tag(url_for("/uploads/assets/$logo"), array('alt' => $site_name, 'class' => 'toplogo'));
	
			?>
	
			<?php else:
			  echo $site_name;
			endif;
			if (!is_null($site_url)): ?>
			</a>
			<?php endif;  ?>
<!--	
			<?php if (apAuthpuppyConfig::getConfigOption("show_node_info", false)): ?>
			  <br/>
			  <?php echo __('There are %1% active nodes in the network.', array('%1%' => Doctrine_Core::getTable('Node')->getDeployedNodes()->count())) ?><br/>
		      <?php echo __('There are %1% active connections.', array('%1%' => Doctrine_Core::getTable('Connection')->getActiveConnections()->count())) ?>
			<?php endif; ?>
-->
	
		</div>
		<div class="row">
		    <?php if ($sf_user->hasFlash('notice')): ?>
			<div class="notice"><?php echo __($sf_user->getFlash('notice')) ?></div>
		    <?php endif; ?>
	     
		    <?php if ($sf_user->hasFlash('error')): ?>
			<div class="error"><?php echo __($sf_user->getFlash('error')) ?></div>
		    <?php endif; ?>
		</div>	
		
		<div class="row-fluid">
			<div id="dashboard_links" class="col-xs-12 col-sm-2 pull-right">
				<ul class="nav nav-pills nav-stacked">
					<li class="active"><a href="#" class="tab-link" id="system">System</a></li>
					<li><a href="#" class="tab-link" id="server">Server</a></li>
					<li><a href="#" class="tab-link" id="permissions">Permissions</a></li>
				</ul>
			</div>
			<div id="dashboard_tabs" class="col-xs-12 col-sm-10">
				<div id="dashboard-system" class="row">
					<p><?php echo __('There are %1% active nodes in the network.', array('%1%' => Doctrine_Core::getTable('Node')->getActiveNodes()->count())) ?></p>
					<p><?php echo __('There are %1% active connections.', array('%1%' => Doctrine_Core::getTable('Connection')->getActiveConnections()->count())) ?></p>

					<a href="<?php echo url_for('node_index'); ?>"><?php echo __("Remove filters"); ?></a>
					<?php include_partial('node/filterForm', array('form' => $filter)) ?>

					<table id="ticker-table" class="table m-table table-bordered table-hover table-heading">
					<thead>
					  <tr>
					    <th><?php echo __('Node Name') ?></th>
					    <th><?php echo __('GW ID') ?></th>
					    <th><?php echo __('WAN IP') ?></th>
					    <th><?php echo __('WD Uptime') ?></th>
					    <th><?php echo __('Last HB') ?></th>
					    <th><?php echo __('Active Connections') ?></th>
					    <th><?php echo __('Deployment status') ?></th>
					  </tr>
					</thead>
					<?php foreach ($nodes as $node) : ?>
					  <?php if ($node->isOnline()) : ?>
					    <tr class="online">
					  <?php else : ?>
					    <tr class="offline">
					  <?php endif ?>

					    <td><a href="<?php echo url_for('node/show?id='.$node->getId()) ?>"><?php echo $node->getName(); ?></a></td>
					    <td><?php echo $node->getGwId(); ?></td>
					    <td><?php echo $node->getLastHeartbeatIp(); ?></td>
					    <td>
					      <?php if ($node->getLastHeartbeatWifidogUptime()) : ?>
					      <?php echo time_ago_in_words(time() - $node->getLastHeartbeatWifidogUptime()); ?>
					      <?php endif ?>
					    </td>
					    <td>
					      <?php if ($node->getLastHeartbeatAt()) : ?>
					      <?php echo time_ago_in_words(date_format(date_create($node->getLastHeartbeatAt()), "U")); ?>
					      <?php endif ?>
					    </td>
					    <td><?php echo $node->getNumActiveConnections(); ?></td>
					    <td><?php echo $node->getDeploymentStatus(); ?></td>

					  </tr>
					<?php endforeach ?>
					</table>

					  <a href="<?php echo url_for('node/new') ?>"><?php echo __("New"); ?></a>
				</div>
				<div id="dashboard-server" class="row">

				</div>
				<div id="dashboard-permissions" class="row">

				</div>

				<div id="menu" class="span-7 last">
				    <?php $languages = apAuthpuppyConfig::getConfigOption("available_languages", array());
				      if (count($languages) > 1) {
					include_component('home', 'language');
				      } ?>  
				</div>
			</div>
			<div class="clearfix"></div>
		</div>
	</div>
</div>
<!--End Content-->
